<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点我!</button>
    <div>某个司吉安</div>
    <p></p>
    <script>

        //inner Text不识别html标签 
        let btn = document.querySelector('button');
        let div = document.querySelector('div');
        btn.onclick = function(){
           div.innerText = getDate()
        }
        function getDate(){
            var date =  new Date();
           var year = date.getFullYear()
           var month = date.getMonth()+1;
           var dates = date.getDate();
           var arr = ['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
           var day = date.getDay();
           return '今天是'+year + '年' + month   +'月'  + dates + '日' +arr[day];
        }
        // getDate()直接页面刷新就获取到时间
        var p = document.querySelector('p');
        p.innerText = getDate()
    </script>
</body>
</html>